//
//  MatchSingleCollectionViewCell.m
//  MyDIYHouse
//
//  Created by dlios on 15-6-30.
//  Copyright (c) 2015年 李平洋. All rights reserved.
//

#import "MatchSingleCollectionViewCell.h"
#import "MySingleCollectionViewCell.h"
#import "SingleModel.h"

#define HEIGHT [UIScreen mainScreen].bounds.size.height
#define WIDTH [UIScreen mainScreen].bounds.size.width


@implementation MatchSingleCollectionViewCell


- (void)dealloc {
    [_myCollectionView release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
        //创建collectionView
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
        flowLayout.itemSize = CGSizeMake((WIDTH - 30 ) / 2, (HEIGHT - 64 - 49 - 30) / 2);
        //设置行间距
        flowLayout.minimumLineSpacing = 10;
        //设置列间距
        flowLayout.minimumInteritemSpacing = 10;
        //设置四周间距
        flowLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
        //设置横向滑动
        //flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        
        self.myCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 64 - 49) collectionViewLayout:flowLayout];
        self.myCollectionView.backgroundColor = [UIColor colorWithRed:218 / 255.0 green: 218 / 255.0 blue:242 / 255.0 alpha:1];
        // self.myCollectionView.dataSource = self;
        //self.myCollectionView.delegate = self;
        //self.myCollectionView.pagingEnabled = YES;
        [self.contentView addSubview:self.myCollectionView];
        [_myCollectionView release];
        //注册(collection的重用池)
        //第一个参数:需要指定注册的类型,如果用自定义cell,,UICollectionViewCell换成自己的
        //第二个参数:重用标志
        //        [self.myCollectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"reuse10"];
        
        [self.myCollectionView  registerClass:[MySingleCollectionViewCell class] forCellWithReuseIdentifier:@"reuse10"];
        
        
    }
    return self;
    
}

#pragma mark collectionView协议方法
//- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
//    return 6;
//}
//
//- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
////    //如果用自定义cell,,UICollectionViewCell换成自己的
////    UICollectionViewCell * cell= [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse10" forIndexPath:indexPath];
////        //使用了注册,就不需要判断是否为空,(因为指定了不为空)
////        cell.contentView.backgroundColor = [UIColor cyanColor];
//
//    MySingleCollectionViewCell * cell= [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse10" forIndexPath:indexPath];
//    //使用了注册,就不需要判断是否为空,(因为指定了不为空)
//    cell.contentView.backgroundColor = [UIColor cyanColor];

//
//
//
//
//
//    return cell;
//
//
//}


@end
